/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Module configuration.
 *//*
 * LEGAL:   COPYRIGHT (C) 2009 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#define SOUND_CONF_CC 1
#include <fstream>
#include "base/module.hh"
#include "base/conf.hh"
#include "base/conf_template_macros.hh"
#include "base/misc.hh"
#include "base/stream.hh"
using namespace base;
#include "sound/module.hh"
#include "sound/conf.hh"

namespace sound {

////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////  Conf  ///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

namespace global { Conf gConf; }

/*****************************************************************************
 * ctor/dtor.
 *****************************************************************************/
Conf::Conf( void )
:   mValid(false),
    // cmd-line args
    mEnableSound(true),
    mPermanentlyDisabled(false)
    // .conf file
{
    // NOP
}

/*****************************************************************************
 * Initialize/read configuration.
 *****************************************************************************/
void
Conf::Init( const base::InitArgs& initArgs, const string& confTxtFilename )
{
    CONF_TEMPLATE_Init_ParseCmdline_ReadConfTxt;
}

/*****************************************************************************
 * Parse cmdline args.
 *****************************************************************************/
void
Conf::ParseCmdlineArgs( int argc, char** argv )
{
    // NOP
}

void
Conf::ParseCmdlineArgs2( int argc, char** argv )
{
    for ( int i = 1; i < argc; ++i )
    {
        if ( STREQ( argv[i], "-ns" )
          or STREQ( argv[i], "-no-sound" )
          or STREQ( argv[i], "-no-audio" ) )
        {
            // Disable sound.
            mEnableSound         = false;
            mPermanentlyDisabled = true;
            CLOG << "Disabled sound." << std::endl;
        }
        else if ( STREQ( argv[i], "-sound" )
               or STREQ( argv[i], "-audio" ) )
        {
            // Enable sound.
            mEnableSound         = true;  // doesn't mean sound is available
            mPermanentlyDisabled = false;
        }
    }
}

/*****************************************************************************
 * Read from .conf file.
 *****************************************************************************/
void
Conf::ReadConfTxt( const string& confTxtFilename )
{
    CONF_TEMPLATE_ReadConfTxt;
}

void
Conf::ModuleConfTxt::ProcessField( string& field, std::ifstream& conf )
{
    // NOP
}

/*****************************************************************************
 * Print Conf configuration.
 *****************************************************************************/
std::ostream& operator<<( std::ostream& strm, const Conf& conf )
{
    // NOP
    return strm;
}

} // namespace sound
